package org.test;

import org.apache.commons.math3.util.FastMath;

/**
 * 定义GPS点和转换函数
 */
public class CoordinateConverter {
    public static GPSPoint cv2ToGPS(GPSPoint baseGPS, double x, double y, double shift, double scale) {
        double xShifted = (x - shift) / scale;
        double yShifted = (y - shift) / scale;
        double baseLatRad = Math.toRadians(baseGPS.lat);
        double baseLngRad = Math.toRadians(baseGPS.lng);
        double rLat = baseGPS.lat + (180 * yShifted / (Math.PI * GPSUtils.EARTH_RADIUS));
        double rLng = baseGPS.lng + (180 * xShifted / (Math.PI * GPSUtils.EARTH_RADIUS * FastMath.cos(baseLatRad)));
        return new GPSPoint(rLng, rLat);
    }

}
